package com.centit.airplanebaseinfo.po;

import com.centit.framework.components.CodeRepositoryUtil;
import com.centit.framework.components.OperationLogCenter;
import com.centit.support.algorithm.UuidOpt;
import org.springframework.security.access.method.P;

import java.util.HashMap;
import java.util.Map;

public class SMSUtils {
    private static String spCode = CodeRepositoryUtil.getSysConfigValue("spCode");
    private static String loginName = CodeRepositoryUtil.getSysConfigValue("loginName");
    private static String passWord = CodeRepositoryUtil.getSysConfigValue("passWord");

    private static String smsUrl = CodeRepositoryUtil.getSysConfigValue("smsUrl");

    public static String templateIdJh = CodeRepositoryUtil.getSysConfigValue("templateId_jh");
    public static String templateIdYq = CodeRepositoryUtil.getSysConfigValue("templateId_yq");
    public static String templateIdDtzz = CodeRepositoryUtil.getSysConfigValue("templateId_dtzz");

    public static void sendMsg(String phoneNumber,String content,String templateId){
        try {
            Map<String, String> sendData=new HashMap<>();
            sendData.put("SpCode",spCode);
            sendData.put("LoginName",loginName);
            sendData.put("Password",passWord);
            sendData.put("MessageContent",content);
            sendData.put("UserNumber",phoneNumber);
            sendData.put("templateId",templateId);

            //String result=SendHttpClientUtil.doPost("https://api.ums86.com:9600/sms/Api/Send.do", JSON.toJSONString(sendData));
            String responseBody=HttpsPost.sendPost(smsUrl,sendData);//可用
            OperationLogCenter.logNewObject("MsgUtils", "SMSUtils", UuidOpt.getUuidAsString32(),
                    "sendMsg",responseBody,  sendData);
        }catch (Exception e) {

            e.printStackTrace();
        }
    }
}
